//
//  SXComposeBtn.swift
//  sina
//
//  Created by shengxinwei on 16/5/28.
//  Copyright © 2016年 shengxinwei. All rights reserved.
//

import UIKit

let imageHeight: CGFloat = 80

class SXComposeBtn: UIButton {

    var composeModel: SXCompose? {
        didSet {
            setTitle(composeModel?.title, forState: .Normal)
            setImage(UIImage(named: composeModel?.icon ?? ""), forState: .Normal)
            titleLabel?.textAlignment = .Center
            titleLabel?.font = UIFont.systemFontOfSize(14.0)
            //tintColor = UIColor.redColor()

        }
    }
    
    //设置button 文字
    override func titleRectForContentRect(contentRect: CGRect) -> CGRect {
        return CGRect(x: 0, y: imageHeight , width: imageHeight, height: contentRect.height - imageHeight)
    }
    //设置按钮中图片位置高度
    override func imageRectForContentRect(contentRect: CGRect) -> CGRect {
        return CGRect(x: 0, y: 0, width: imageHeight, height: imageHeight)
    }
}
